package menu;

import java.util.Iterator;
import java.util.Map;
import saves.Save;

/**
 *
 * @author Luan
 */
public class SaveLoadMenu extends SimpleMenu {

    private boolean save;

    public SaveLoadMenu(int itemCode, String name, boolean save) {
        super(itemCode, name, null, null);
        this.save = save;
        this.actionCode = (save ? 1 : 0);
    }

    public int getSave() {
        return Integer.parseInt(items[selectedItem].text);
    }

    @Override
    public void draw() {
        items = new SimpleMenu.SimpleMenuItem[profile.getQtosSaves() + actionCode];
        Iterator<Map.Entry<Integer, Save>> it = profile.getSet().iterator();
        if (save)
            items[0] = new SimpleMenu.SimpleMenuItem(-1, "Novo save", null);
        for (int i = actionCode; it.hasNext(); i++) {
            Map.Entry<Integer, Save> e = it.next();
            items[i] = new SimpleMenu.SimpleMenuItem(-1, String.valueOf(e.getKey()), null);
        }

        super.draw();
    }
}